<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let name = "张三"
    let age = 10
    let p = {
      name,
      age,
      hobby: ['打排球', '打篮球'],
      say: function () {
        console.log('say()--');
      },
      eat () {
        console.log('学习');
      },
      ['stu' + 'dy'] () {
        console.log('学习');
      }

    }
    // console.log(name);
    // console.log(p);
    // p.say()
    // p.study()

    console.log(p);
    let p2 = { ...p }//浅拷贝
    p2.name = "李四"
    p2.hobby[1] = '羽毛球'
    console.log(p2);

    let stu = {
      height: 175,
      weight: 60
    }

    let p3 = { ...p, ...stu }//合并对象, 重名覆盖
    console.log(p3);

  </script>
</body>

</html>